import { defineStore } from 'pinia'
import { List } from 'vant'
import {http} from '../apis/user'

export const useStore = defineStore('goods-store', {
  state: () => ({ 
     cartList:[List],
  }),
  getters: {
  },
  actions: {
    changeCartList(list:any){
      this.cartList=list.map((item:any)=>{
        item.checked=true;
        return item
      })
      sessionStorage.setItem("cartList",JSON.stringify(this.cartList))
    },
    changeCartListAsync() {   
      http.getCartList().then(data => {
        this.changeCartList(data.data ||[])
      })
    }
  }
})
